package com.guoyw.seata.storage.controller;

import com.guoyw.seata.common.dto.CommodityDTO;
import com.guoyw.seata.common.response.ObjectResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 前端控制器
 * author: guoyw
 * create: 2020-09-19 17:29
 **/

@RestController
@RequestMapping("/storage")
@Slf4j
public class TStorageController{
  @Autowired
  private ITStorageService storageService;
  
  /**
   * 扣减库存
   */
  @PostMapping("dec_storage")
  ObjectResponse decreaseStorage(@RequestBody CommodityDTO commodityDTO){
    log.info("请求库存微服务：{}",commodityDTO.toString());
    return storageService.decreaseStorage(commodityDTO);
  }
}
